package net.minecraft.src;

import java.util.Random;
import net.minecraft.src.forge.*;

public class BlockVillageChest extends BlockChest implements ITextureProvider {
	
	public static final String displayName = "Village Chest";
	public static final String blockName = "VillageChest";
	
	public static final float blockHardness = 0.50f; //2.5f;
	public static final StepSound stepSound = Block.soundWoodFootstep;
	
	protected BlockVillageChest(int blockID) {
		super(blockID);
		blockIndexInTexture = 0;
		
		setBlockName(blockName);
		setHardness(blockHardness);
		setStepSound(stepSound);
		setRequiresSelfNotify();
		
		ModLoader.RegisterBlock(this);
		ModLoader.RegisterTileEntity(TileEntityVillageChest.class, "VillageChestEntity", new TileEntityVillageChestRenderer(ModLoader.getMinecraftInstance().theWorld));
		ModLoader.AddName(this, displayName);
		ModLoader.AddRecipe(new ItemStack(this, 1), new Object[] {
			"PPP",
			"PGP",
			"PPP",
			'P', Block.planks,
			'G', Item.ingotGold
		});
	}
	
	@Override
    public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
    	super.onBlockClicked(world, x, y, z, player);
    	player.addChatMessage("I AM VILLAGE CHEST. FEAR ME.");
    }
    
    @Override
    public void onBlockPlaced(World world, int x, int y, int z, int l) {
    	super.onBlockPlaced(world, x, y, z, l);
    	
    	Random rand = new Random();
    	
    	ModLoader.getMinecraftInstance().thePlayer.addChatMessage(String.format("%d %d %d", new Object[] {x, y, z}));
    	EntityTehVillager villager = new EntityTehVillager(world);
    	villager.setPositionAndRotation(x - 4 + rand.nextFloat() * 8, y, z - 4 + rand.nextFloat() * 8, rand.nextFloat() * 360, 0);
    	world.spawnEntityInWorld(villager);
    }
    
    public TileEntity getBlockEntity()
    {
        return new TileEntityVillageChest();
    }
    
    public String getTextureFile() {
    	return mod_TehMod.blockTexture;
    }
    
    public int getRenderType() {
    	return mod_TehMod.chestModelID;
    }
}
